﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Virgee.Common.Interfaces
{
    /// <summary>
    /// A interface that defines the protocol to serialize/deserialize an object to/from <see cref="T:System.String"/>
    /// </summary>
    public interface ISerializer
    {
        /// <summary>
        /// Serializes the given input object to a <see cref="T:System.String"/> format.
        /// </summary>
        /// <typeparam name="T">The input type.</typeparam>
        /// <param name="input">The input value.</param>
        /// <param name="additionalInfo">Used to pass additional information that may be required by the serializer to serialize the input object.</param>
        /// <returns>Returns a <see cref="T:System.String"/> instance representing the serialized object.</returns>
        string Serialize<T>(T input, IDictionary<string, object> additionalInfo = null) where T : class;

        /// <summary>
        /// Deserializes the given <see cref="T:System.String"/> format to an instance of an object of the specified type.
        /// </summary>
        /// <typeparam name="T">The type.</typeparam>
        /// <param name="input">The <see cref="T:System.String"/> input.</param>
        /// <param name="additionalInfo">Used to pass additional information that may be required by the serializer to deserialize the input <see cref="T:System.String"/>.</param>
        /// <returns>Returns an instance of the specified T deserialized from the given <see cref="System.String"/>.</returns>
        T Deserialize<T>(string input, IDictionary<string, object> additionalInfo = null) where T : class;

        /// <summary>
        /// Returns the media type used by the serializer.
        /// </summary>
        string MediaType { get; }
    }
}
